//
//@File    :	14.8_worker0.cpp
//@Time    :	2022/01/20 15:09:42
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	working class methods
//

#include <iostream>
#include "14.7_Worker0.h"
using std::cin;
using std::cout;
using std::endl;

//Worker methods
//must impement virtual detructor,even if pure
Worker::~Worker() {}

void Worker::Set()
{
    cout << "Enter worker's name: ";
    getline(cin, fullname);
    cout << "Enter wrker's ID: ";
    cin >> id;
    while (cin.get() != '\n')
        continue;
}

void Worker::Show() const
{
    cout << "Name: " << fullname << "\n";
    cout << "Employee ID: " << id << "\n";
}

//Waiter mathods
void Waiter::Set()
{
    Worker::Set();
    cout << "Enter waiter's panache rating: ";
    cin >> panache;
    while (cin.get() != '\n')
        continue;
}

void Waiter::Show() const
{
    cout << "Catagory:waiter\n";
    Worker::Show();
    cout << "Panache rating: " << panache << "\n";
}

//Singer methods
//出现以下问题,猜测涉及强制类型转换
/*14.8_worker0.cpp:54:51: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
             "soprano", "bass", "baritone", "tenor"};
                                                   ^
*/ 
char * Singer::pv[] = {"other", "alto", "contralto",
            "soprano", "bass", "baritone", "tenor"};
void Singer::Set()
{
    Worker:Set();
    cout<<"Enter number for singer's vocal range:\n";
    int i;
    for ( i = 0; i < Vtypes; i++)
    {
        cout<<i<<": "<<pv[i]<<"   ";
        //数组从零开始,四个一行
        if (i%4==3)
        {
            cout<<endl;
        }
    }
    if (i%4!=0)
    {
        cout<<endl;
    }
    while (cin>>voice &&(voice<0||voice>=Vtypes))
    {
        cout<<"Please enter a value >=0 and <"<<Vtypes<<endl;
    }
    while (cin.get()!='\n')
    {
        continue;
    }
    
}

void Singer::Show() const
{
    cout<<"Category:singer\n";
    Worker::Show();
    cout<<"Vocal range: "<<pv[voice]<<endl;
}